
use "${source_data}\Buyer_Characteristics.dta", clear
merge 1:1 b_id using "${source_data}\orbis_qje.dta"
drop if _merge==2
drop _merge n_b Mainactivity
drop new_main_activity
drop TotalassetslastvalueDate
replace Maindomesticcountry="United States of America" if Maindomesticcountry=="United States Of America"
gen x=usubstr(Dateofincorporation,-4,4)
drop Dateofincorporation
destring x, gen(Dateofincorporation)
drop x Mainactivit
save "${replicated_data}\Data_with_ORBIS.dta",replace

use "${replicated_data}\Data_with_ORBIS.dta",clear

keep if b_in_sample==1

gen lassets=ln(Totala)
gen lsales=ln(OperatingrevenueTurnoverUSD)
gen lemployees=ln(Numberofemployees2010)
gen lmarketcap=ln(CurrentmarketcapitalisationUS)
gen lgross=ln(Grossmargin2010)
encode Maindomesticcountry, gen(maincountry)

quietly tabulate main_destination, generate(FE_main_destination)
quietly tabulate main_product, generate(FE_main_product)
quietly tabulate main_activity, generate(FE_main_activity)
quietly tabulate maincountry, generate(FE_main_country)
quietly tabulate Categoryofthecompany, generate(FE_Cat)
replace Dateofincorporation=2004 if Dateofincorporation<=2004 & Dateofincorporation!=.
replace Dateofincorporation=2012 if Dateofincorporation>=2012 & Dateofincorporation!=.
quietly tabulate Dateofincorporation, generate(FE_Dateofincorporation)
quietly tabulate cohort_b, generate(FE_cohort)

* Labels
label var sourcing " $ Relational_b $ "
label var cohort_b " $ Cohort_b $ "
label var Dateofincorporation " $ Date \ of \ incorporation_b $ "
label var lassets " $ Assets_b   $ "
label var lsales " $ Sales_b   $ "
label var lemployees " $ Employees_b   $ "
label var ln_pop   " $ Population_d $ " 
label var ln_gdp   " $ GDP_d $ " 
label var ln_gdppc " $ GDPPC_d $ " 

* ------------------------------------------------------------------------------ *
* TABLE C9. Sourcing Strategies and Destination and Buyer Characteristics
* ------------------------------------------------------------------------------ *

do "${floats}\TableC9.do"

